<?php
	namespace Admin\Controller;
	use Think\Controller;
/**
 * 前台导航菜单 管理控制器
 */
 class MenuController extends  IsLoginController{
 	/*
	 * 管理首页
	 */
	 public function index(){
	 	$menu = M("navigation")->select();
		//实例化扩展类 栏目树
		$list = new \Org\Util\Data;
		$menuList = $list::tree($menu,'nname','nid','npid');
		$this->assign('menuList',$menuList);
	 	$this->display();
	 }
	 
	 /**
	  * 添加菜单
	  */
	  public function add(){
	  	if(IS_POST){
	 		$nav = D('navigation');
			if(!$nav->addNav()){
				$this->error($nav->getError());
				return false;
			}
			$this->success('添加成功');
	 	}
		$menu = M("navigation")->select();
		//实例化扩展类 栏目树
		$list = new \Org\Util\Data;
		$menuList = $list::tree($menu,'nname','nid','npid');
		$this->assign('menuList',$menuList);
	  	$this->display();
	  }
	 
	 /**
	  * 修改菜单
	  */
	 public function edit(){
	 	if(IS_POST){
	 		$nav = D('navigation');
			if(!$nav->editNav()){
				$this->error($nav->getError());
				return false;
			}
			$this->success('修改成功');
	 	}
	 	$nid = I('get.nid');
		$nidData = M('navigation')->where("nid='{$nid}'")->find();
		$this->assign('nidData',$nidData);
	 	$menu = M("navigation")->select();
		//实例化扩展类 栏目树
		$list = new \Org\Util\Data;
		$menuList = $list::tree($menu,'nname','nid','npid');
		$this->assign('menuList',$menuList);
	 	$this->display();
	 }
	 
 }
